package com.it.travel.controller.admin;

import com.it.travel.pojo.Story;
import com.it.travel.service.admin.AdminStoryService;
import com.it.travel.service.admin.AdminUserService;
import com.it.travel.vo.Params.PageParams;
import com.it.travel.vo.Params.admin.AdminStoryAddParams;
import com.it.travel.vo.Params.admin.AdminStoryUpdateParams;
import com.it.travel.vo.Params.admin.AdminUserParams;
import com.it.travel.vo.Params.admin.AdminUserUpdateParams;
import com.it.travel.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/admin/story")
@CrossOrigin
public class AdminStoryController {
    @Resource
    private AdminStoryService adminStoryService;

    @GetMapping("")
    public Result<?> getStoryInfoPage(PageParams pageParams) {
        Result<?> result = adminStoryService.getStoryInfoPage(pageParams);
        return result;
    }


    @PostMapping("")
    public Result<?> save(@RequestBody AdminStoryAddParams adminStoryAddParams) {
        Result<?> result = adminStoryService.save(adminStoryAddParams);
        return result;
    }
    @DeleteMapping("/{id}")
    public Result<?> delete(@PathVariable("id") Integer id) {
        Result<?> result = adminStoryService.delete(id);
        return result;
    }

    @PutMapping("")
    public Result<?> update(@RequestBody AdminStoryUpdateParams adminStoryUpdateParams) {
        Result<?> result = adminStoryService.update(adminStoryUpdateParams);
        return result;
    }
//
    @PostMapping("/deletebatch")
    public Result<?> deletebatch(@RequestBody List<Integer> ids) {
        Result<?> result = adminStoryService.deletebatch(ids);
        return result;
    }

    @GetMapping("/detail/{id}")
    public Result<?> findProductDetail(@PathVariable("id") Integer id) {
        Result<?> result = adminStoryService.findStoryDetail(id);
        return result;
//        return null;
    }

//    @PutMapping("/detail/{id}")
//    public Result<?> updateStoryDetail(@RequestBody AdminStoryUpdateParams adminStoryUpdateParams) {
//        Result<?> result = adminStoryService.updateStoryDetail(adminStoryUpdateParams);
//        return result;
//    }
}
